<?php
/**
 * Created by Zend Studio.
 * User: FDG348
 * @param  FDG348 2018-03-23  553 【后台需求】用户在心愿单界面预约到店后，后台可查看用户预约到店时心愿单商品
 * Date: 2018/03/23
 * Time: 9:15
 */
namespace backend\models;

use yii\db\ActiveRecord;

class ShareWishReserv extends ActiveRecord{
    public static function tableName(){
        return '{{%share_wish_reserv}}';
    }
	const ADDRESS_TYPE_ONE	=1;//闵行店
	const ADDRESS_TYPE_TWO	=2;//浦东店

	const RESERV_TIME_EX_ONE	=1;//1:上午（10:00-12:00）
	const RESERV_TIME_EX_TWO	=2;//2:下午（12:00-18:00）
	const RESERV_TIME_EX_THR	=3;//3：晚上（18:00-20:00）

	public static  $address_arr=[
		self::ADDRESS_TYPE_ONE=>'上海，吴中路1265号',
		self::ADDRESS_TYPE_TWO=>'上海，东方路1833号',

	];

	public static  $reserv_arr=[
		self::RESERV_TIME_EX_ONE=>'上午（10:00-12:00）',
		self::RESERV_TIME_EX_TWO=>'下午（12:00-18:00）',
		self::RESERV_TIME_EX_THR=>'晚上（18:00-20:00）',
	];

	public function rules(){
		return [
			[['wish_list_id','reserv_name','reserv_mobile','cust_id','cust_mobile','address_type','reserv_time','reserv_time_ex','create_time'],'safe'],
			[['reserv_mobile'],'match','pattern'=>'/^\d{11}$|\d{3}-\d{8}|\d{4}-\d{7,8}/'],
			[['reserv_name','reserv_mobile'],'required','message'=>'必填'],
		];
	}

	/**
	 * @获取创建人
	 */
	public function getCreator(){
	    $userInfo = \common\helps\tools::getloginUserInfo();
	    if($userInfo){
	        $userName = $userInfo->userName;
	    }else{
	        $userName = '';
	    }
	    return $userName;
	}
	
	public function getShareWishList()
	{
	    return $this->hasOne(ShareWishList::className(), ['id'=>'wish_list_id']);
	}
}